    <?php defined('BASEPATH') OR exit('No direct script access allowed'); ?><!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/public/js/html5shiv.js"></script>
    <script type="text/javascript" src="/public/js/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/Hui-iconfont/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/laydate/skins/default/laydate.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="/public/js/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>快方管理后台</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <style type="text/css">
        .date{
            width: 100px;
        }
        .table .show_count{
            text-align: right;
            padding-right: 10px;
        }
        .search{
            width: 250px;
        }
        .title{
            padding-left: 20px;
        }
        .addCategory,.modCategory{
            display: none;
        }
    </style>
</head>
<body class="big-page">
<div class="Hui-article" style="top:0;">
    <h3 class="title">同步商品<small>&emsp;<?=$chn_name?></small></h3>
    <h5 class="title">待处理&emsp;<span class='c-blue'><?=$queue_cnt?></span></h5>
    <article class="cl pd-20" style="padding-top: 0px;">

        <div class="control">
            <a href="#" class="commit_sync_product btn radius">提交商品</a>
            <a class="go_back btn-primary btn radius">返回</a>
        </div>
        <div class="mt-10">
            <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive" id="productList">
                <thead>
                    <tr>
                        <td colspan="6"><input type="text" class="search input-text radius" name="search"></td> 
                        <td colspan="1" class="show_count"></td> 
                    </tr>
                    <tr class="text-c">
                        <th>#</th>
                        <th>KFID</th>
                        <th>分类名称</th>
                        <th>药品名称</th>
                        <th>药品规格</th>
                        <th>生产厂家</th>
                        <th>价格</th>
                    </tr>
                </thead>
                
                <tbody>

                </tbody>
            </table>
        </div>
    </article>
    <input type="hidden" name="store_id" value="<?=$_GET['store_id']?>">
    <input type="hidden" name="chn_id" value="<?=$_GET['chn_id']?>">
</div>

<script type="text/javascript" src="/public/js/jquery.min.js"></script>
<script type="text/javascript" src="/public/plugins/layer/layer.js"></script>
<script type="text/javascript" src="/public/plugins/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/public/plugins/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/public/plugins/jquery.contextmenu/jquery.contextmenu.r2.js"></script>
<script type="text/javascript" src="/public/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/public/plugins/laydate/laydate.js"></script>
<script type="text/javascript">
    var loading = layer.msg('处理中', {
      icon: 16
      ,shade: 0.5
    });
    $.ajax({
        url: window.location.href,
        type: "POST",
        dataType: "json",
        success: function(res){
            layer.close(loading);
            var html = "";
            var i = 1;
            for(k in res.data){
                var data = res.data[k];

                html += "<tr>";
                html += "<td>" + i + "</td>";
                html += "<td>" + data.ID + "</td>";
                html += "<td>" + data.category_name + "</td>";
                html += "<td>" + data.Caption + "</td>";
                html += "<td>" + data.ModeSize + "</td>";
                html += "<td>" + data.CompanyName + "</td>";
                html += "<td>" + data.LSJG + "</td>";
                html += "</tr>";

                i++;
            }
            $(".show_count").html("共&emsp;" + (i-1) + "&emsp;条记录")
            $("#productList tbody").html(html)
        }
    })

    $("input[name='search']").bind("keyup",function() {
        var text = $(this).val();

        $("#productList tbody tr").hide();

        if(text.length > 0){
            $("#productList tbody tr").each(function(){
                var product_name = $("td:eq(3)", this).text();
                var company_name = $("td:eq(5)", this).text();
                var product_id = $("td:eq(1)", this).text();

                if(product_name.indexOf(text) > -1){
                    $(this).show();
                }

                if(company_name.indexOf(text) > -1){
                    $(this).show();
                }

                if(product_id == text){
                    $(this).show();
                }
            })
        }else{
            $("#productList tbody tr").show();
        }
    })

    $(".commit_sync_product").bind("click", function(){
        var chn_id = $("input[name='chn_id']").val();
        var store_id = $("input[name='store_id']").val();
        var commit_url = "/ChannelProduct/commitSyncProduct?chn_id=" + chn_id + "&store_id=" + store_id;

        var loading = layer.msg('处理中', {
          icon: 16
          ,shade: 0.5
        });
        $.ajax({
            url: commit_url,
            type: "POST",
            dataType: "json",
            success: function(res){
                layer.close(loading);
                window.location.reload();
            }
        })
    })

    $(".go_back").bind("click", function(){
        window.history.back();
    })
</script>
</body>
</html>
